# Group Group
Groups consisting of events.

| Parameter | Description | Type | Required |
|:----------|-------------|------|----------|
| `name`  | Name of the group | string | **yes** |



## Group Collection [/v1/groups{?page%5bsize%5d,page%5bnumber%5d,sort,filter}]
+ Parameters
    + page%5bsize%5d (optional, integer, `10`) - Maximum number of resources in a single paginated response.
    + page%5bnumber%5d (optional, integer, `1`) - Page number to fetched for the paginated response.
    + sort (optional, string, `name`) - Sort the resources according to the given attribute in ascending order. Append '-' to sort in descending order.
    + filter (optional, string, `[]`) - Filter according to the flask-rest-jsonapi filtering system. Please refer: http://flask-rest-jsonapi.readthedocs.io/en/latest/iltering.html for more.
### List All Groups [GET]
Get a list of groups.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
            "meta": {
                "count": 1
            },
            "data": [
                        {
                            "type": "group",
                            "relationships": {
                                "events": {
                                    "links": {
                                        "self": "/v1/groups/1/relationships/events",
                                        "related": "/v1/groups/1/events"
                                    }
                                },
                                "user": {
                                    "links": {
                                        "self": "/v1/groups/1/relationships/user",
                                        "related": "/v1/groups/1/user"
                                    }
                                }
                            },
                            "attributes": {
                                "name": "eventgp1",
                                "deleted-at": null
                            },
                            "id": "1",
                            "links": {
                                "self": "/v1/groups/1"
                            }
                        }
    
            ],
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/groups"
            }
        }

### Create Group [POST]
Create a new group with event_id.

+ Request (application/vnd.api+json)

    + Headers

            Authorization: JWT <Auth Key>

    + Body

    {
        "data": {
            "type": "group",
            "id": "1",
            "relationships": {
                "user":{
                    "data":{
                        "id":"1",
                        "type":"user"
                    }
                },
                "events": {
                    "data": [
                        {
                        "id": "1",
                        "type": "event"
                    }
                    ]
                }
                
            },
            "attributes": {
                "name": "eventgp1"
            }
        }
    }


+ Response 201 (application/vnd.api+json)

    {
        "data": {
            "type": "group",
            "relationships": {
                "events": {
                    "links": {
                        "self": "/v1/groups/1/relationships/events",
                        "related": "/v1/groups/1/events"
                    }
                },
                "user": {
                    "links": {
                        "self": "/v1/groups/1/relationships/user",
                        "related": "/v1/groups/1/user"
                    }
                }
            },
            "attributes": {
                "name": "eventgp1",
                "deleted-at": null
            },
            "id": "1",
            "links": {
                "self": "/v1/groups/1"
            }
        },
        "links": {
            "self": "/v1/groups/1"
        },
        "jsonapi": {
            "version": "1.0"
        }
    }


## Group Detail [/v1/groups/{group_id}]
+ Parameters
    + group_id: 1 (integer) - ID of the group in the form of an integer

### Group Detail [GET]
Get a single group.

+ Request

    + Headers

            Accept: application/vnd.api+json

+ Response 200 (application/vnd.api+json)

        {
        "data": {
            "type": "group",
            "relationships": {
                "events": {
                    "links": {
                        "self": "/v1/groups/1/relationships/events",
                        "related": "/v1/groups/1/events"
                    }
                },
                "user": {
                    "links": {
                        "self": "/v1/groups/1/relationships/user",
                        "related": "/v1/groups/1/user"
                    }
                }
            },
            "attributes": {
                "name": "eventgp1",
                "deleted-at": null
            },
            "id": "1",
            "links": {
                "self": "/v1/groups/1"
            }
        },
        "links": {
            "self": "/v1/groups/1"
        },
        "jsonapi": {
            "version": "1.0"
        }
    }


### Update Group [PATCH]
Update a single group with `id`.

+ `id` (integer) - ID of the record to update **(required)**

+ Request (application/vnd.api+json)

    + Headers

            Authorization: JWT <Auth Key>

    + Body

            {
              "data": {
                "type": "group",
                "attributes": {
                    "name": "eventgp-random"
                },
                "id": "1"
              }
            }


+ Response 200 (application/vnd.api+json)

        {
        "data": {
            "type": "group",
            "relationships": {
                "events": {
                    "links": {
                        "self": "/v1/groups/1/relationships/events",
                        "related": "/v1/groups/1/events"
                    }
                },
                "user": {
                    "links": {
                        "self": "/v1/groups/1/relationships/user",
                        "related": "/v1/groups/1/user"
                    }
                }
            },
            "attributes": {
                "name": "eventgp_random",
                "deleted-at": null
            },
            "id": "1",
            "links": {
                "self": "/v1/groups/1"
            }
        },
        "links": {
            "self": "/v1/groups/1"
        },
        "jsonapi": {
            "version": "1.0"
        }
    }

### Delete Group [DELETE]
Delete a single group.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
          "meta": {
            "message": "Object successfully deleted"
          },
          "jsonapi": {
            "version": "1.0"
          }
        }

## Get Group for an Event [/v1/events/{event_id}/group]
+ Parameters
    + event_id: 1 (integer) - ID of the group in the form of an integer

### Group Details for an Event [GET]
Get a single group.

+ Request

    + Headers

            Accept: application/vnd.api+json

+ Response 200 (application/vnd.api+json)

        {
        "data": {
            "type": "group",
            "relationships": {
                "events": {
                    "links": {
                        "self": "/v1/groups/1/relationships/events",
                        "related": "/v1/groups/1/events"
                    }
                },
                "user": {
                    "links": {
                        "self": "/v1/groups/1/relationships/user",
                        "related": "/v1/groups/1/user"
                    }
                }
            },
            "attributes": {
                "name": "eventgp_1",
                "deleted-at": null
            },
            "id": "1",
            "links": {
                "self": "/v1/groups/1"
            }
        },
        "links": {
            "self": "/v1/groups/1"
        },
        "jsonapi": {
            "version": "1.0"
        }
    }


## Groups under an User [/v1/users/{user_id}/groups{?page%5bsize%5d,page%5bnumber%5d,sort,filter}]
+ Parameters
    + user_id: 1 (integer) - ID of the user in the form of an integer
    + page%5bsize%5d (optional, integer, `10`) - Maximum number of resources in a single paginated response.
    + page%5bnumber%5d (optional, integer, `1`) - Page number to fetched for the paginated response.
    + sort (optional, string, `name`) - Sort the resources according to the given attribute in ascending order. Append '-' to sort in descending order.
    + filter (optional, string, `[]`) - Filter according to the flask-rest-jsonapi filtering system. Please refer: http://flask-rest-jsonapi.readthedocs.io/en/latest/iltering.html for more.
### List All Groups under an User [GET]
Get a list of groups.

+ Request

    + Headers

            Accept: application/vnd.api+json

            Authorization: JWT <Auth Key>

+ Response 200 (application/vnd.api+json)

        {
            "meta": {
                "count": 1
            },
            "data": [
                        {
                            "type": "group",
                            "relationships": {
                                "events": {
                                    "links": {
                                        "self": "/v1/groups/1/relationships/events",
                                        "related": "/v1/groups/1/events"
                                    }
                                },
                                "user": {
                                    "links": {
                                        "self": "/v1/groups/1/relationships/user",
                                        "related": "/v1/groups/1/user"
                                    }
                                }
                            },
                            "attributes": {
                                "name": "eventgp1",
                                "deleted-at": null
                            },
                            "id": "1",
                            "links": {
                                "self": "/v1/groups/1"
                            }
                        }
    
            ],
            "jsonapi": {
                "version": "1.0"
            },
            "links": {
                "self": "/v1/users/1/groups?page%5Bsize%5D=10&page%5Bnumber%5D=1&sort=name&filter=%5B%5D"
            }
        }
